/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package sampledata.genomemap.data;

import commons.nb.data.DNDataList_DirBased;
import org.openide.modules.InstalledFileLocator;

import java.io.File;

/**
 * Bundles a directory containing N.crassa genome data.
 *
 * @version 1.0.0
 * @author Susanta Tewari
 * @since 1.0.0
 */
public class DNDataList_DirBased_OrganismData extends DNDataList_DirBased {

    public DNDataList_DirBased_OrganismData() {

        super("Organism Genome Data", "genomemap/data/organismdata", "genomemap.sampledata");

        process_children();
    }

    /**
     * each child directory corresponds to one organism data.
     */
    private void process_children() {

        for (final File orgDataDir : dir.listFiles()) {

            if (!orgDataDir.isDirectory()) throw new RuntimeException("only expecting directory");

            final String orgDataDirName    = orgDataDir.getName();
            final File file = InstalledFileLocator.getDefault().locate(RELATIVE_DIR_PATH + "/"
                                  + orgDataDirName, MODULE_CNB, false);
            final String SHORT_DESCRIPTION = "Organism data in DIR format";

            addData(new DNData_DirBased_OrganismData(orgDataDirName, SHORT_DESCRIPTION,
                    "1,2,3,4,5,6,7", file.getAbsolutePath()));
        }
    }
}
